using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Runtime.Serialization;
using System.Data.Objects.DataClasses;
using DIS_DAL_WS.Models;

namespace DIS_DAL_WS.DTO
{
    [DataContract]
    public class CustomerDTO
	{
        [DataMember]
		public int ID { get; set; }
        [DataMember]
        public string Name { get; set; }
        [DataMember]
        public string Phone { get; set; }
        [DataMember]
        public string Address { get; set; }
        [DataMember]
        public string Email { get; set; }
        [DataMember]
        public string UserName { get; set; }
        [DataMember]
        public string Password { get; set; }

        public static CustomerDTO Translate(Customer Entity)
        {
            if (Entity != null)
            {
                var dto = new CustomerDTO
                {
                    ID = Entity.ID,
                    Name = Entity.Name,
                    Phone = Entity.Phone,
                    Address = Entity.Address,
                    Email = Entity.Email,
                    UserName = Entity.UserName,
                    Password = Entity.Password
                };
                return dto;
            }
            return null;
        }

        public static Customer Reverse(CustomerDTO obj)
        {
            var entity = new Customer
            {
                ID = obj.ID,
                Name = obj.Name,
                Phone = obj.Phone,
                Address = obj.Address,
                Email = obj.Email,
                UserName = obj.UserName,
                Password = obj.Password
            };
            return entity;
        }

        public void UpdateEntity(ref Customer entity)
        {
            entity.Name = Name;
            entity.Phone = Phone;
            entity.Address = Address;
            entity.Email = Email;
            entity.UserName = UserName;
            entity.Password = Password;
        }
	}
}